package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

public class JDBCDemo3 {
    public static void main(String[] args) throws Exception {
        try (
                Connection connection = DBUtil.getConnection();
                ) {
            System.out.println("与数据库建立连接！");
            //3.创建语句对象
            Statement statement = connection.createStatement();
            String sql = "UPDATE userinfo " +
                    "SET password = '88888888' " +
                    "where username = '张蒙蒙'";
            System.out.println(sql);
            int count = statement.executeUpdate(sql);
            if (count >0) {
                System.out.println("修改成功");
            }
            //connection.close();//继承了aotucloseable，不用手动关闭
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
